package com.gitee.wsl.prism4j.languages

import com.gitee.wsl.prism4j.Prism4j
import com.gitee.wsl.prism4j.Prism4j.Companion.grammar
import com.gitee.wsl.prism4j.Prism4j.Companion.pattern
import com.gitee.wsl.prism4j.Prism4j.Companion.token
import com.gitee.wsl.prism4j.Prism4j.Pattern

@Suppress("unused")
object Prism_git {
    fun create(prism4j: Prism4j): Prism4j.Grammar {
        return grammar(
            "git",
            token("comment", pattern(Pattern.compile("^#.*", Pattern.MULTILINE))),
            token("deleted", pattern(Pattern.compile("^[-–].*", Pattern.MULTILINE))),
            token("inserted", pattern(Pattern.compile("^\\+.*", Pattern.MULTILINE))),
            token("string", pattern(Pattern.compile("(\"|')(?:\\\\.|(?!\\1)[^\\\\\\r\\n])*\\1", Pattern.MULTILINE))),
            token(
                "command", pattern(
                    Pattern.compile("^.*\\$ git .*$", Pattern.MULTILINE),
                    false,
                    false,
                    null,
                    grammar(
                        "inside",
                        token("parameter", pattern(Pattern.compile("\\s--?\\w+", Pattern.MULTILINE)))
                    )
                )
            ),
            token("coord", pattern(Pattern.compile("^@@.*@@$", Pattern.MULTILINE))),
            token("commit_sha1", pattern(Pattern.compile("^commit \\w{40}$", Pattern.MULTILINE)))
        )
    }
}
